package com.tfjybj.itoo.exam.provider.service.impl;

import com.dmsdbj.itoo.tool.base.service.impl.BaseServicePlusImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.exam.entity.TemplateDetailsExtractEntity;
import com.tfjybj.itoo.exam.model.QuestionMainModel;
import com.tfjybj.itoo.exam.provider.dao.TemplateDetailsExtractDao;
import com.tfjybj.itoo.exam.provider.service.TemplateDetailsExtractService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * TemplateDetailsExtractService接口实现类
 * ${base}表
 *
 * @author 任晓帅
 * @version 2.0.0
 * @since 2.0.0 2018-11-15 19:40:28
 */
@Service("templateDetailsExtractService")
public class TemplateDetailsExtractServiceImpl extends BaseServicePlusImpl<TemplateDetailsExtractDao, TemplateDetailsExtractEntity> implements TemplateDetailsExtractService {
	

    @Resource
    private TemplateDetailsExtractDao templateDetailsExtractDao;

	 @Override
    public PageInfo<TemplateDetailsExtractEntity> queryByLikeQuestionId(String questionId, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(templateDetailsExtractDao.queryLikeQuestionId(questionId));
    }


    //endregion

    /* **********************************以下为非模板生成的内容********************************* */
    /**
     * 添加模板必抽题
     * @param templateDetailsExtractEntity 模板必抽题
     * @author 杨海云
     * @since 2.0.0 2018年11月29日08:24:30
     */
    @Override
    public int installTemp(TemplateDetailsExtractEntity templateDetailsExtractEntity) {

        return templateDetailsExtractDao.insert(templateDetailsExtractEntity);
    }

    @Override
    public List<QuestionMainModel> queryQueExtractByTemplateId(String templatedetailsId) {
        return templateDetailsExtractDao.queryQueExtractByTemplateId(templatedetailsId);
    }

    @Override
    public List<TemplateDetailsExtractEntity> queryDetilsExtractBytemplateDetailsId(String templateDetsilsId) {
        return templateDetailsExtractDao.queryDetilsExtractBytemplateDetailsId(templateDetsilsId);
    }

    @Override
    public  Boolean updateQuestionId(String wrongQuestionId,String newQuestionId ){
        return templateDetailsExtractDao.updateQuestionId(wrongQuestionId,newQuestionId);
    }

    /**
     * 插入模板明细表
     *
     * @param tempDEList 模板明细集合
     * @return true/false
     * @author 马莹
     * @since 2019年2月9日19:41:04
     */
    @Override
    public boolean installRandomQuestions(List<TemplateDetailsExtractEntity> tempDEList) {
        return this.saveBatch(tempDEList);
    }
}
